<!--
 * @Author: 刘十三
 * @Date: 2024-01-04 15:13:21
 * @LastEditors: 刘十三
 * @LastEditTime: 2024-04-10 15:16:52
 * @FilePath: \NM-dev-1.3.1\dev\pages\internal\linkage\check\multiMemberQuery.vue
 * @Description: 内蒙多员联动 - 多员联动台账（列表）
-->

<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <u-icon name="search" color="#FFF" size="38" style="margin: 0 24rpx 0 6rpx" @tap="openSearch"></u-icon>
    </theme-navbar>
    <!-- #endif -->

    <!-- #ifdef H5-WECHAT -->
    <fab-button :content="fContent" @fabtrigger="fabtrigger" />
    <!-- #endif -->

    <!-- 列表 -->
    <view class="content">
      <me-table :i="0" :index="0" :top="20" :load-data="loadData" :init-load="false" ref="mescrollItem0">
        <template slot-scope="d">
          <view style="margin-bottom: 20rpx;">
            <u-card :showHead="false" :showFoot="false" padding="20" :border="false" margin="0">
              <multiMemberQueryItem slot="body" class="n-lay" :seal-info="d.data" />
            </u-card>
          </view>
        </template>
      </me-table>
    </view>

    <!-- 组织机构选择 -->
    <u-popup v-model="orgSelectShow" mode="bottom" height="80%" :z-index="19999">
      <org-select :cleanParentOrg="true" :isHybrid="true" limitNodeType="03" treeType="zm-comp" @choose="handlerChooseOrg"></org-select>
    </u-popup>
    <!-- 反馈类型 -->
    <u-popup v-model="categoryShow" mode="bottom" height="80%" :z-index="19999">
      <treeSelect @choose="handlerChooseCate" :list="categoryCodeOptions"></treeSelect>
    </u-popup>

    <!-- 搜索条件 -->
    <u-popup v-model="searchVisable" width="80%" mode="right">
      <view class="cearch_title">
        查询条件
      </view>
      <u-form :model="serachForm" label-position="top" label-width="auto" style="padding: 80rpx 32rpx 120rpx 32rpx;" ref="uForm">
        <template v-if="searchVisable">
          <u-form-item label="所属组织:" prop="issueOrgUuid">
            <u-input placeholder="请选择" disabled v-model="issueOrgName" @click="orgSelectShow = true" />
          </u-form-item>
          <u-form-item label="编号:" prop="code">
            <u-input placeholder="请输入" v-model="serachForm.code" />
          </u-form-item>
          <u-form-item label="反馈类型:" prop="categoryCode">
            <u-input placeholder="请选择" disabled v-model="categoryName" @click="categoryShow = true" />
          </u-form-item>
          <u-form-item label="企业字号:" prop="retatlerName">
            <u-input placeholder="请输入" v-model="serachForm.retatlerName" />
          </u-form-item>
          <u-form-item label="反馈日期:" prop="feedbackDateStart">
            <z-date placeholder="请选择" v-model="serachForm.feedbackDateStart" style="padding-right:5px" />
            <z-date placeholder="请选择" v-model="serachForm.feedbackDateEnd" style="padding-left:5px" />
          </u-form-item>
          <u-form-item label="安排情况:" prop="plannStatus">
            <u-radio-group v-model="serachForm.plannStatus">
              <u-radio name="0">未安排</u-radio>
              <u-radio name="1">已安排</u-radio>
            </u-radio-group>
          </u-form-item>
          <u-form-item label="安排日期:" prop="planDateStart">
            <z-date placeholder="请选择" v-model="serachForm.planDateStart" style="padding-right:5px" />
            <z-date placeholder="请选择" v-model="serachForm.planDateEnd" style="padding-left:5px" />
          </u-form-item>
          <u-form-item label="核查情况:" prop="checkMatchStatus">
            <u-radio-group v-model="serachForm.checkMatchStatus">
              <u-radio name="0">核查一致</u-radio>
              <u-radio name="1">核查不一致</u-radio>
            </u-radio-group>
          </u-form-item>
          <u-form-item label="处置结果:" prop="executeResult" :border-bottom="false">
            <u-input placeholder="请输入" v-model="serachForm.executeResult" />
          </u-form-item>
        </template>
      </u-form>
      <view class="submit-btns btn-other-cls">
        <u-button plain class="del" type="primary" @tap="handleRest">
          重置
        </u-button>
        <u-button class="mit" type="primary" @tap="selectChange">
          确定
        </u-button>
      </view>
    </u-popup>
  </view>
</template>

<script>
import { ZDate, OrgSelect, MeTable } from "@/components";
import fabButton from "@/components/uni-fab.vue";
import treeSelect from "./components/treeSelect.vue";

import multiMemberQueryItem from "./components/multiMemberQueryItem.vue";
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import linkageService from "@/service/internal/linkeage.service";
export default {
  components: {
    ZDate,
    MeTable,
    fabButton,
    OrgSelect,
    treeSelect,
    multiMemberQueryItem,
  },
  mixins: [MescrollMoreMixin],
  data() {
    return {
      searchVisable: false,
      serachForm: {
        page: 1,
        limit: 10,
        feedbackDateStart: "",
        feedbackDateEnd: "",
        retailerName: "",
        code: "",
        categoryCode: "",
        issueOrgUuid: "",
        plannStatus: "",
        planDateStart: "",
        planDateEnd: "",
        checkMatchStatus: "",
        executeResult: "",
      },
      fContent: [
        {
          iconPath: require("@/static/search.png"),
          selectedIconPath: require("@/static/search.png"),
          text: "搜索",
          active: false,
        },
      ],
      categoryCodeOptions: [],
      categoryShow: false,
      orgSelectShow: false,
      issueOrgName: "",
      categoryName: "",
    };
  },
  methods: {
    openSearch() {
      this.searchVisable = true;
    },
    selectChange() {
      if (this.serachForm.feedbackDateStart && this.serachForm.feedbackDateEnd) {
        if (new Date(this.serachForm.feedbackDateStart) > new Date(this.serachForm.feedbackDateEnd)) {
          return this.$u.toast("反馈开始日期不能大于反馈结束日期");
        }
      }
      if (this.serachForm.planDateStart && this.serachForm.planDateEnd) {
        if (new Date(this.serachForm.planDateStart) > new Date(this.serachForm.planDateEnd)) {
          return this.$u.toast("安排开始日期不能大于安排结束日期");
        }
      }
      this.searchVisable = false;
      this.handleReferList();
    },
    handleRest() {
      this.serachForm = {
        feedbackDateStart: "",
        feedbackDateEnd: "",
        retatlerName: "",
        code: "",
        issueOrgUuid: "",
        plannStatus: "",
        categoryCode: "",
        planDateStart: "",
        planDateEnd: "",
        checkMatchStatus: "",
        executeResult: "",
      };
      this.issueOrgName = "";
      this.categoryName = "";
    },
    loadData(pager) {
      let self = this;
      self.serachForm.page = pager.num;
      self.serachForm.limit = pager.size;
      return new Promise((resolve) => {
        linkageService
          .getTaskFickleReportList(self.serachForm)
          .then((res) => {
            if (res.success) {
              resolve({
                data: res.data,
                count: res.count,
              });
            } else {
              self.$modal.alert(res.msg);
              resolve({
                data: [],
                count: 0,
              });
            }
          })
          .catch((err) => {
            resolve({
              data: [],
              count: 0,
            });
          });
      });
    },
    fabtrigger(btn) {
      if (btn.index == 0) {
        this.openSearch();
      }
    },
    handleReferList() {
      let mescroll = this.getMescroll(0);
      mescroll && mescroll.triggerDownScroll();
    },
    handlerChooseOrg(orgs) {
      this.serachForm.issueOrgUuid = orgs[0].id;
      this.issueOrgName = orgs[0].name;
      this.orgSelectShow = false;
    },
    handlerChooseCate(row) {
      this.serachForm.categoryCode = row.code;
      this.categoryName = row.name;
      this.categoryShow = false;
    },
    getFeedbackType() {
      let self = this;
      self.$modal.showLoading("加载中...");
      let param = {
        sourceCode: "1001",
      };
      linkageService
        .getFeedbackType(param)
        .then((res) => {
          self.$modal.hideLoading();
          if (res.success) {
            self.categoryCodeOptions = res.data;
          } else {
            self.$u.toast(res.msg);
          }
        })
        .catch((err) => {
          self.$modal.hideLoading();
        });
    },
  },
  created() {
    this.getFeedbackType();
  },
};
</script>

<style lang="scss" scoped>
.page {
  padding: 0;
}

/deep/ .u-radio-group{
  width: 100%;
  justify-content: space-between;
}

.content {
  padding: 0 24rpx;
  background: #f5f5f5;
}

.swipe-list {
  background: #ffffff;
  margin-bottom: 24rpx;
  overflow: hidden;
  border-radius: 5px;
}

.cearch_title {
  background-color: #f3f4f5;
  width: 100%;
  height: 82rpx;
  font-size: 32rpx;
  font-weight: 600;
  padding: 22rpx 0 21rpx 32rpx;
  z-index: 999;
  position: fixed;
}
.content-h {
  height: calc(100vh - 200px);
  overflow-y: scroll;
}
</style>
